package com.wdc.deliveryrobot.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wdc.deliveryrobot.R;
import com.wdc.deliveryrobot.event.Event;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class RunActivity extends BaseActivity {

    private ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_run);
        imageView = findViewById(R.id.image_max);

        if (imageView != null) {
            // 从 Intent 中获取传递的图片资源
            Intent intent = getIntent();
            int imageRes = intent.getIntExtra("imageResource", R.drawable.loading);
            Glide.with(this)
                    .asGif()
                    .load(R.drawable.loading) // 加载图片
                    .into(imageView);
        } else {
            // 如果控件没有找到，输出日志
            Log.e("RunActivity", "ImageView 控件未找到！");
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    if (selfChassisState.getResult() == 1 || selfChassisState.getResult() == -2) {
                        finish();  // 关闭 RunActivity，返回之前的 Activity
                        break;
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("thd_","点击了屏幕");
                //点击屏幕显示暂停界面

            }
        });
    }


//    public void setImageView(int id){
//        imageView.setImageResource(id);
//    }
@Subscribe(threadMode = ThreadMode.MAIN)
public void OnDataEvent(Event.OnDataEvent onDataEvent){

}
}